package rkdwogus7.practice;

public class Ex72 {

	public static void main(String[] args) {
		RetangleServiceImpl rs = new RetangleServiceImpl();
		// 인터페이스 만들고 충상메서드 클래스에서 구현
		Retangle r = new Retangle(1.0, 1.0);
		r.setArea(rs.getArea(r)); // 변수에 값 저장
		r.setCircum(rs.getCircum(r));
		System.out.println(r.toString());
		
		
	} // main

	
	
} // class

class Retangle {
	private double width;
	private double height;
	private double area;
	private double circum;
	
	public Retangle() { }

	public Retangle(double width, double height) {
		this.width = width;
		this.height = height;
	}
	
	public double getArea() {
		return area;
	}
	
	public void setArea(double area) {
		this.area = area;
	}
	
	public void setCircum(double circum) {
		this.circum = circum;
	}
	
	public double getCircum() {
		return circum;
	}
	
	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
	}

	public double getHeight() {
		return height;
	}

	public void setHeight(double height) {
		this.height = height;
	}

	@Override
	public String toString() {
		return "Retangle [너비=" + width + ", 높이=" + height + ", 면적="
				+ area + ", 둘레=" + circum + "]";
	}
	


}

interface RetangleService {
	double getArea( Retangle r );
	double getCircum( Retangle r );
}

class RetangleServiceImpl implements RetangleService {

	@Override
	public double getArea(Retangle r) {
		double area = r.getWidth() * r.getHeight();
		return area;
	}

	@Override
	public double getCircum(Retangle r) {
		double circum = (r.getWidth() + r.getHeight()) * 2;
		return circum;
	}
	
}









